//
//  DownLoadCell.m
//  JZMCFM
//
//  Created by Mc on 15/11/7.
//  Copyright (c) 2015年 陈卓. All rights reserved.
//

#import "DownLoadCell.h"
#import "VideoDownLoadManager.h"

@implementation DownLoadCell

- (void)awakeFromNib {
    self.headerImageView.layer.cornerRadius = 10;
    self.headerImageView.clipsToBounds = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setCellDataWithModel:(DetailModel2 *)model
{
    [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:model.coverLarge]];
    self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%",model.progressValue * 100];
    self.progressView.progress = model.progressValue;
    self.titleL.text = model.title;
    if (model.isDownFinished) {
        self.palseAndPlayButton.userInteractionEnabled = NO;
        
    }else{
        self.palseAndPlayButton.userInteractionEnabled = YES;
        
    }
}

// 更新下载进度
- (void)updateDownLoadProgress:(DetailModel2 *)model
{
    self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%",model.progressValue * 100];
    self.progressView.progress = model.progressValue;
}

- (IBAction)palseAndPlayButtonDidClicked:(id)sender {
    if (self.palseAndPlayButton.isSelected) {
        [self.palseAndPlayButton setImage:[UIImage imageNamed:@"zanting"] forState:UIControlStateNormal];
    }else{
        [self.palseAndPlayButton setImage:[UIImage imageNamed:@"iconfont-bofang"] forState:UIControlStateNormal];
    }
    self.palseAndPlayButton.selected = !self.palseAndPlayButton.selected;
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(MEDownLoadCellpalseAndPlayButtonDidClicked:withIsPlay:)]) {
        [self.delegate MEDownLoadCellpalseAndPlayButtonDidClicked:self withIsPlay:self.palseAndPlayButton.selected];
    }
}


@end
